# 构建一个摇骰子的函数
import random
def roll_dice(number=3):
    print('<<<<<  ROLL THE DICE  >>>>>')
    points = []
    while number > 0:
        point = random.randrange(1, 7)
        points.append(point)
        number = number - 1
    return points

# 将点数转换成大小
def roll_result(total):
    isBig = 11 <= total <= 18
    isSmall = 3 <= total <= 10
    if isBig:
        return 'Big'
    elif isSmall:
        return 'Small'

# 游戏结束
def game_over():
    print('<<<<<  GAME OVER!  >>>>>')

# 创建游戏的开始函数
def start_game(money):
    print('<<<<<  GAME STARTS!  >>>>>')
    choices = ['Big', 'Small']
    PLevel = 1
    your_choices = input('Big or Small :')
    if your_choices in choices:
        bat = int(input('How much you wanna bat ? -'))
        if bat <= money:
            point = roll_dice()
            total = sum(point)
            youWin = your_choices == roll_result(total)
            if youWin :
                print('The point are', point, 'You Win !')
                money2 = money + (bat * PLevel)
                print('You gained {} ,you have {} now'.format(money, money2))
                money = money2
                start_game(money)
            else:
                print('The point are', point, 'You Lose !')
                money2 = money - (bat * PLevel)
                print('You lost {} ,you have {} now'.format(money, money2))
                money = money2
                if money == 0:
                    game_over()
                else:
                    start_game(money)
        else:
            print('Error Bat!')
            start_game(money)
    else:
        print('Error Word!')
        start_game(money)

start_game(1000)